package main

import (
	"log"
	"mzxk/nono"
	"tcp_test/models"
)

const (
	SERVER_IP       = "127.0.0.1"
	SERVER_PORT     = 10006
	SERVER_RECV_LEN = 4 * 1024 //读取4k数据
)

var mongo *nono.Mongo

func init() {
	url := nono.GetDBURL()
	//rds = nono.NewRedis(url.Redis, url.RedisPwd, 8)
	mongo = nono.NewMongo(url.Mongo, "user")
}

type InParam struct {
	Collection string      `json:"collection"` //表结构
	Selector   interface{} `json:"selector"`   //条件
	Update     interface{} `json:"update"`     //更新
	Operation  string      `json:"operation"`  //操作
	DB         string      `json:"db"`         //数据库
}

func main() {
	/*address := SERVER_IP + ":" + strconv.Itoa(SERVER_PORT)
	listener, err := net.Listen("tcp", address)
	if err != nil {
		fmt.Println(err)
		os.Exit(1)
	}

	defer listener.Close()*/

	/*log.Println("run")
	for {
		conn, err := listener.Accept()
		if err != nil {
			fmt.Println(err)
			continue
		}
		fmt.Println("add:", conn.RemoteAddr().String())
		go handleConn(conn)
	}*/
	handleConn()
}

func handleConn() {
	mongo = nono.NewMongo("mongodb://apitest.ggbtc.cc:13149", "eth-usdt")
	log.Println("mongo connect", mongo)
	models.Do(mongo)
}
